﻿using JiveMessenger.Models;
using System;
using System.Collections.Generic;
using System.Text;
using Windows.ApplicationModel;
using Windows.UI.Xaml;

namespace JiveMessenger.Utilities.TemplateSelector
{
    public class ContactGroupHeaderTemplateSelector:DataTemplateSelector
    {
        public DataTemplate JiveChatGroupHeader
        {
            get;
            set;
        }

        public DataTemplate JiveFriendsGroupHeader
        {
            get;
            set;
        }
        
        public override DataTemplate SelectTemplate(
    object item, DependencyObject container)
        {
            if (DesignMode.DesignModeEnabled)
            {
                Random rnd = new Random((int)DateTime.Now.Ticks);
                int n = rnd.Next(1, 10);
                if (n >= 3 && n <= 5)
                    return JiveChatGroupHeader;
                else if (n > 5 && n <= 8)
                    return JiveChatGroupHeader;
                else
                    return JiveChatGroupHeader;


            }
            VisualGroup vGrp = item as VisualGroup;
            if (vGrp != null)
            {
                if (vGrp.Group is JiveChatGroupModel)
                    return JiveChatGroupHeader;
                else if (vGrp.Group is JiveFriendsGroupModel)
                    return JiveFriendsGroupHeader;
            }

            return base.SelectTemplate(item, container);
        }
    }
}
